--- %%NOBANNER%% -->
/*-------------------<---Start of Description-->---------------------\
| Centeralize a text string in the SAS output window; |
|---------------------<---End of Description-->----------------------|
|--------------------------------------------------------------------|
|------------<---Start of Files or Arguments Needed-->---------------|
| A string or a quoted string will be needed; |
|---------------<---End of Files Arguments Needed-->-----------------|
|--------------------------------------------------------------------|
|------------------<---Start of Files Created-->---------------------|
| Example: title %center(%initcaps("this is a text")); |
| Usage: %center(string); |
\-------------------<---End of Files Created-->---------------------*/
%macro center/parmbuff;
/*--------------------------------------------\
| Author: Duo Zhou; |
| Created: 9-16-2001 8:25pm; |
| Purpose: Centralize a string of text; |
\--------------------------------------------*/
%local _centertexttxt1_ _centertexttxt2_ _centertext_ _centerlinesize_ _centerindent_ _centernewtext_;
%let _centerlinesize_ = %SYSFUNC(GETOPTION(linesize));
%if (%length(%nrbquote(&syspbuff)) gt 2) %then %do;
%let _centertexttxt1_=%nrbquote(%substr(%nrbquote(&syspbuff), 2, %eval(%length(%nrbquote(&syspbuff))-2)));
%let _centertexttxt2_=%nrbquote(%sysfunc(dequote(%nrbquote(&_centertexttxt1_))));
%if (%index(%nrbquote(&_centertexttxt1_),%nrbquote(&_centertexttxt2_)) >1) %then
%let _centernumofspace_ = %EVAL(&_centerlinesize_ - %LENGTH(%nrbquote(&_centertexttxt2_)));
%else %let _centernumofspace_ = %EVAL(&_centerlinesize_ - %LENGTH(%nrbquote(&_centertexttxt1_)));
%LET _centerindent_ = %EVAL(&_centernumofspace_/2);
%let _centernewtext_=;
%do _i_=1 %to &_centerindent_;
%let _centernewtext_=&_centernewtext_%str( );
%end;
%if (%index(%nrbquote(&_centertexttxt1_),%nrbquote(&_centertexttxt2_)) >1) %then %do;
%if (%index(%nrbquote(&_centertexttxt2_),%str(%"))) %then
%let _centernewtext_=%nrbquote(%sysfunc(tranwrd(%nrbquote(&_centertexttxt2_),%str(%"),%str(%'))));
%let _centernewtext_=&_centernewtext_"&_centertexttxt2_";
%end;
%else %let _centernewtext_=%nrbquote(&_centernewtext_.&_centertexttxt1_);
&_centernewtext_
%end;
%MEND center;